
import 'package:baselib/util/const_config.dart';
import "package:get/get.dart";
import 'package:web_socket_channel/io.dart';
class WebSocketService extends GetxService{
  void init() async {
// if(GetPlatform.isWeb){
    //   var channel = HtmlWebSocketChannel.connect(
    //       ConstConfig.DEV_SOCKET_URL);
    //   channel?.stream?.listen((message) {
    //     print("收到服务器数据:" + message);
    //   },onError: (error){
    //     print("webs"+error.toString());
    //   });
    //   channel.sink.add('{\"type\":\"authorization\",\"token\":\"411\"}');
    //
    //  channel.sink.close();
    //
    // }else {
    var channel = IOWebSocketChannel.connect(
        ConstConfig.DEV_SOCKET_URL);
    channel?.stream?.listen((message) {
      print("收到服务器数据:" + message);
    });

    channel.sink.add('{\"type\":\"authorization\",\"token\":\"411\"}');
    // }
  }
}